<HTML>
    <HEAD>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>网卡信息测试页面</title>
  <script type="text/javascript" src="./js/service.js"></script>
  <script type="text/javascript" src="/usr/share/javascript/jquery/jquery.min.js"></script>
  <script src="./js/qwebchannel.js"></script>
      <TITLE>网卡信息测试页面</TITLE>
      <SCRIPT language=JavaScript>
              var websocket_url = 'ws://localhost:12345';
              var websocket = null;

              if (websocket === null) {
                  websocket = new WebSocket(websocket_url);
                  websocket.onopen = function () {
                      console.log("connect websocketserver success");
                  }
              } else {
                  websocket.close();
                  websocket = null;
              }

              function getNetCardName() {
                  console.log("getNetCardName")
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardName();
                          }
                      );
              }
              function getNetCardUp() {
                  console.log("getNetCardUp")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardUp(pid);
                          }
                      );
              }
              function getNetCardUpcards() {
                  console.log("getNetCardUpcards")
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardUpcards();
                          }
                      );
              }

              function getNetCardPhymac() {
                  console.log("getNetCardPhymac")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardPhymac(pid);
                          }
                      );
              }
              function getNetCardPrivateIPv4() {
                  console.log("getNetCardPrivateIPv4")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardPrivateIPv4(pid);
                          }
                      );
              }
              function getNetCardIPv4() {
                  console.log("getNetCardIPv4")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardIPv4(pid);
                          }
                      );
              }
              function getNetCardPrivateIPv6() {
                  console.log("getNetCardPrivateIPv6")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardPrivateIPv6(pid);
                          }
                      );
              }
              function getNetCardType() {
                  console.log("getNetCardType")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardType(pid);
                          }
                      );
              }
              function getNetCardProduct() {
                  console.log("getNetCardProduct")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardProduct(pid);
                          }
                      );
              }
              function getNetCardIPv6() {
                  console.log("getNetCardIPv6")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var res = document.getElementById("res");
                          var netcard = channel.objects.netcard;
                          netcard.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              res.innerHTML = message;
                          });
                          netcard.getNetCardIPv6(pid);
                          }
                      );
              }
              
        //-->
      </SCRIPT>
      <META content="MSHTML 6.00.2900.6287" name=GENERATOR>
      <style>
        table tr td{padding: 5px;}
      </style>
  
    </HEAD>
    <BODY>
      <div style="margin:30 5 20 5">
        <div>
          <input onclick="getNetCardName()" type="button" value="网卡名称"  style="width: 100px; height: 50px">
          <input onclick="getNetCardUp()" type="button" value="网卡是否处于UP状态"  style="width: 100px; height: 50px">
          <input onclick="getNetCardUpcards()" type="button" value="处于 link up 状态的网卡列表"  style="width: 100px; height: 50px">
          <input onclick="getNetCardPhymac()" type="button" value="网卡的物理MAC地址"  style="width: 100px; height: 50px">
          <input onclick="getNetCardPrivateIPv4()" type="button" value="网卡的第一个IPv4地址"  style="width: 100px; height: 50px">
          <input onclick="getNetCardIPv4()" type="button" value="网卡的所有IPv4地址"  style="width: 100px; height: 50px">
          <input onclick="getNetCardPrivateIPv6()" type="button" value="网卡的第一个IPv6地址"  style="width: 100px; height: 50px">
          <input onclick="getNetCardType()" type="button" value="网卡类型"  style="width: 100px; height: 50px">
          <input onclick="getNetCardProduct()" type="button" value="网卡厂商型号"  style="width: 100px; height: 50px">
          <input onclick="getNetCardIPv6()" type="button" value="网卡的所有IPv6地址"  style="width: 100px; height: 50px">
        </div>
        <div id="input_box2">
            <h3>网卡名称:</h3>
            <label>
              <input type="text" id="pid" style="height: 30px; width: 200px;" placeholder="输入网卡名称">
            </label>
          </div>
        <div style="margin-top:20">
          <div align=left style="margin:5 0 5 0">回复：</div>
          <div>
          <textarea id="res" style="width:1000px;height:500px" ></textarea>
          </div>
        </div>
      </div>
    </BODY>
  </HTML>
  